# -*- coding:utf-8 -*-
# __author__ : "张百科"
# Date: 2021/1/25 16:48
# File: experience.py
# IDE: PyCharm

from rest_framework import serializers
from models.experience import Experience

class ExperienceSerializer(serializers.ModelSerializer):
    process=serializers.CharField(label='装修阶段', max_length=50,  help_text='装修阶段')
    process_display = serializers.SerializerMethodField(read_only=True)
    title = serializers.CharField(label='标题', help_text='标题', required=True,max_length=100)
    list_pic_url = serializers.CharField(label='列表图片', help_text='列表图片', required=False)
    content= serializers.CharField(label='内容', help_text='内容', required=True)
    read_count = serializers.IntegerField(read_only=True)
    update_time=serializers.DateTimeField(read_only=True)

    def get_process_display(self, obj):
        return obj.get_process_display()

    class Meta:
        model = Experience
        exclude = ('is_delete',)